﻿//using System;
using System.Collections.Generic;
using UnityEngine;
using XUpdater;
using XUtliPoolLib;

namespace XMainClient
{
	// Token: 0x02000EDD RID: 3805
	internal class XBullet
	{
		// Token: 0x1700351C RID: 13596
		// (get) Token: 0x0600C982 RID: 51586 RVA: 0x002D385C File Offset: 0x002D1A5C
		public XBulletCore BulletCore
		{
			get
			{
				return this._data;
			}
		}

		// Token: 0x1700351D RID: 13597
		// (get) Token: 0x0600C983 RID: 51587 RVA: 0x002D3874 File Offset: 0x002D1A74
		public ulong ID
		{
			get
			{
				return this._id;
			}
		}

		// Token: 0x1700351E RID: 13598
		// (get) Token: 0x0600C984 RID: 51588 RVA: 0x002D388C File Offset: 0x002D1A8C
		// (set) Token: 0x0600C985 RID: 51589 RVA: 0x002D38A4 File Offset: 0x002D1AA4
		public ulong ExtraID
		{
			get
			{
				return this._extra_id;
			}
			set
			{
				this._extra_id = value;
			}
		}

		// Token: 0x0600C986 RID: 51590 RVA: 0x002D38B0 File Offset: 0x002D1AB0
		public XBullet(ulong id, XBulletCore data)
		{
			this.Init(id, data);
		}

		// Token: 0x0600C987 RID: 51591 RVA: 0x002D3925 File Offset: 0x002D1B25
		public void Deny()
		{
			this._effectual = false;
		}

		// Token: 0x0600C988 RID: 51592 RVA: 0x002D3930 File Offset: 0x002D1B30
		private void LoadFinish(Object obj, object cbOjb)
		{
			bool flag = this._iFmod != null;
			if (flag)
			{
				this._iFmod.Destroy();
				XSingleton<XUpdater.XUpdater>.singleton.XPlatform.ReturnClass(EClassType.ERuntimeFMOD, this._iFmod);
				this._iFmod = null;
			}
			bool flag2 = !string.IsNullOrEmpty(this._data.Result.LongAttackData.Audio);
			if (flag2)
			{
				this._iFmod = (XSingleton<XUpdater.XUpdater>.singleton.XPlatform.CreateClass(EClassType.ERuntimeFMOD) as IXFmod);
				Rigidbody rigidbody = null;
				GameObject gameObject = obj as GameObject;
				bool flag3 = gameObject != null;
				if (flag3)
				{
					rigidbody = gameObject.GetComponent<Rigidbody>();
				}
				bool flag4 = this._iFmod != null;
				if (flag4)
				{
					this._iFmod.Init(gameObject, rigidbody);
					XSingleton<XAudioMgr>.singleton.PlaySound(this._iFmod, AudioChannel.Motion, this._data.Result.LongAttackData.Audio);
				}
			}
		}

		// Token: 0x0600C989 RID: 51593 RVA: 0x002D3A20 File Offset: 0x002D1C20
		private XFx FilterFx(string path)
		{
			bool flag = string.IsNullOrEmpty(path);
			XFx result;
			if (flag)
			{
				result = XSingleton<XFxMgr>.singleton.CreateFx("", new LoadCallBack(this.LoadFinish), true);
			}
			else
			{
				bool flag2 = XSingleton<XScene>.singleton.FilterFx && (this._data.Firer == null || (!this._data.Firer.IsPlayer && !this._data.Firer.IsBoss && !(this._data.Firer is XDummy))) && (this._data.Target == null || !this._data.Target.IsPlayer);
				if (flag2)
				{
					Vector3 position = XSingleton<XEntityMgr>.singleton.Player.EngineObject.Position;
					Vector3 origin = this._data.BulletRay.origin;
					float num = XFxMgr.FilterFxDis4;
					float num2 = (origin.x - position.x) * (origin.x - position.x) + (origin.z - position.z) * (origin.z - position.z);
					bool flag3 = this._data.Result != null && this._data.Result.LongAttackData != null;
					if (flag3)
					{
						num = this._data.Result.LongAttackData.Velocity * this._data.Result.LongAttackData.Runningtime;
					}
					bool flag4 = num2 < XFxMgr.FilterFxDis4 || num2 < num * num;
					if (flag4)
					{
						result = XSingleton<XFxMgr>.singleton.CreateFx(this._data.Prefab, new LoadCallBack(this.LoadFinish), true);
					}
					else
					{
						result = XSingleton<XFxMgr>.singleton.CreateFx("", new LoadCallBack(this.LoadFinish), true);
					}
				}
				else
				{
					result = XSingleton<XFxMgr>.singleton.CreateFx(path, null, true);
				}
			}
			return result;
		}

		// Token: 0x0600C98A RID: 51594 RVA: 0x002D3C0C File Offset: 0x002D1E0C
		public void Init(ulong id, XBulletCore data)
		{
			this._id = id;
			this._extra_id = 0UL;
			this._active = true;
			this._effectual = true;
			this._tail_results = 0;
			this._pingpong = false;
			this._hit_triggered = false;
			this._elapsed = 0f;
			this._data = data;
			this._origin = Vector3.zero;
			string path = XSingleton<XGlobalConfig>.singleton.PreFilterPrefab(this._data.Prefab);
			this._bullet = this.FilterFx(path);
			this._bullet.Play(this._data.BulletRay.origin, (this._data.Velocity > 0f) ? Quaternion.LookRotation(this._data.BulletRay.direction) : Quaternion.LookRotation(this._data.Firer.EngineObject.Forward), Vector3.one, 1f);
			this._hurt_target.debugName = "XBullet._hurt_target";
			XSingleton<XBulletMgr>.singleton.GetSmallBuffer(ref this._hurt_target, 4);
		}

		// Token: 0x0600C98B RID: 51595 RVA: 0x002D3D18 File Offset: 0x002D1F18
		private void OnRefined(object o)
		{
			ulong num = (ulong)o;
			int i = 0;
			int count = this._hurt_target.Count;
			while (i < count)
			{
				XBullet.XBulletTarget xbulletTarget = this._hurt_target[i];
				bool flag = xbulletTarget.TargetID == num && xbulletTarget.HurtCount < this._data.Result.LongAttackData.Refine_Count;
				if (flag)
				{
					xbulletTarget.Hurtable = true;
					this._hurt_target[i] = xbulletTarget;
					break;
				}
				i++;
			}
		}

		// Token: 0x0600C98C RID: 51596 RVA: 0x002D3DA4 File Offset: 0x002D1FA4
		private void OnRefined()
		{
			int i = 0;
			int count = this._hurt_target.Count;
			while (i < count)
			{
				XBullet.XBulletTarget xbulletTarget = this._hurt_target[i];
				xbulletTarget.Hurtable = true;
				xbulletTarget.HurtCount = 0;
				XSingleton<XTimerMgr>.singleton.KillTimer(xbulletTarget.TimerToken);
				this._hurt_target[i] = xbulletTarget;
				i++;
			}
		}

		// Token: 0x0600C98D RID: 51597 RVA: 0x002D3E0C File Offset: 0x002D200C
		private void OnPingPong()
		{
			this._pingpong = true;
			bool autoRefine_at_Half = this._data.Result.LongAttackData.AutoRefine_at_Half;
			if (autoRefine_at_Half)
			{
				this.OnRefined();
			}
		}

		// Token: 0x0600C98E RID: 51598 RVA: 0x002D3E44 File Offset: 0x002D2044
		public void Expire()
		{
			this._active = false;
			bool flag = this._tail_results != 0;
			if (flag)
			{
				XSingleton<XTimerMgr>.singleton.KillTimer(this._tail_results_token);
				this._tail_results = this._data.Result.LongAttackData.TriggerAtEnd_Count;
			}
		}

		// Token: 0x0600C98F RID: 51599 RVA: 0x002D3E94 File Offset: 0x002D2094
		public bool IsExpired()
		{
			bool flag = !this._effectual || (!this._data.Demonstration && !XEntity.ValideEntity(this._data.Firer));
			bool result;
			if (flag)
			{
				result = true;
			}
			else
			{
				bool flag2 = this._tail_results != 0;
				if (flag2)
				{
					bool flag3 = this._tail_results >= this._data.Result.LongAttackData.TriggerAtEnd_Count;
					result = flag3;
				}
				else
				{
					bool flag4 = this._data.Result.LongAttackData.IsPingPong && !this._pingpong;
					if (flag4)
					{
						bool flag5 = XSingleton<XCommon>.singleton.IsGreater(this._elapsed, this._data.Life);
						if (flag5)
						{
							this.OnPingPong();
						}
					}
					bool flag6 = !this._active || (!this._pingpong && XSingleton<XCommon>.singleton.IsGreater(this._elapsed, this._data.Life));
					bool flag7 = this._data.Result.LongAttackData.TriggerAtEnd_Count <= 0;
					if (flag7)
					{
						result = flag6;
					}
					else
					{
						bool flag8 = flag6;
						if (flag8)
						{
							this._active = false;
							this.OnTailResult(null);
							result = false;
						}
						else
						{
							result = flag6;
						}
					}
				}
			}
			return result;
		}

		// Token: 0x0600C990 RID: 51600 RVA: 0x002D3FE8 File Offset: 0x002D21E8
		private void OnTailResult(object o)
		{
			bool flag = o == null;
			if (flag)
			{
				this._tail_results = 0;
				this.FakeDestroyBulletObject();
			}
			bool flag2 = this._tail_results < this._data.Result.LongAttackData.TriggerAtEnd_Count;
			if (flag2)
			{
				this._tail_results++;
				this.TailResult(this._tail_results == 1);
				XSingleton<XTimerMgr>.singleton.KillTimer(this._tail_results_token);
				this._tail_results_token = XSingleton<XTimerMgr>.singleton.SetTimer(this._data.Result.LongAttackData.TriggerAtEnd_Cycle, new XTimerMgr.ElapsedEventHandler(this.OnTailResult), this);
			}
		}

		// Token: 0x0600C991 RID: 51601 RVA: 0x002D4094 File Offset: 0x002D2294
		public bool IsHurtEntity(ulong id)
		{
			int i = 0;
			int count = this._hurt_target.Count;
			while (i < count)
			{
				XBullet.XBulletTarget xbulletTarget = this._hurt_target[i];
				bool flag = xbulletTarget.TargetID == id;
				if (flag)
				{
					return !xbulletTarget.Hurtable;
				}
				i++;
			}
			return false;
		}

		// Token: 0x0600C992 RID: 51602 RVA: 0x002D40F4 File Offset: 0x002D22F4
		private void TailResult(bool present)
		{
			bool triggerAtEnd = this._data.Result.LongAttackData.TriggerAtEnd;
			if (triggerAtEnd)
			{
				bool warning = this._data.Warning;
				if (warning)
				{
					this._bullet.Position = this._data.WarningPos;
				}
				bool flag = !this._data.Demonstration && !XSingleton<XGame>.singleton.SyncMode;
				if (flag)
				{
					this.Result(null, this._data.Result.LongAttackData.TriggerAtEnd_Count == 0);
				}
			}
			bool flag2 = !present;
			if (!flag2)
			{
				bool flag3 = !string.IsNullOrEmpty(this._data.Result.LongAttackData.End_Fx);
				if (flag3)
				{
					Vector3 position = this._bullet.Position;
					float num = 0f;
					bool flag4 = this._data.Demonstration || XSingleton<XScene>.singleton.TryGetTerrainY(position, out num);
					if (flag4)
					{
						XFx xfx = XSingleton<XFxMgr>.singleton.CreateFx(this._data.Result.LongAttackData.End_Fx, null, true);
						xfx.DelayDestroy = this._data.Result.LongAttackData.EndFx_LifeTime;
						Quaternion rotation = this._bullet.Rotation;
						bool endFx_Ground = this._data.Result.LongAttackData.EndFx_Ground;
						if (endFx_Ground)
						{
							position.y = (this._data.Demonstration ? this._bullet.Position.y : num);
							rotation = (this._data.Demonstration ? Quaternion.identity : XSingleton<XCommon>.singleton.RotateToGround(position, this._bullet.Forward));
						}
						xfx.Play(position, rotation, Vector3.one, 1f);
						XSingleton<XBulletMgr>.singleton.LogEndFx(xfx);
						XSingleton<XFxMgr>.singleton.DestroyFx(xfx, false);
					}
				}
				bool flag5 = !string.IsNullOrEmpty(this._data.Result.LongAttackData.End_Audio);
				if (flag5)
				{
					XSingleton<XAudioMgr>.singleton.PlaySound(this._data.Firer, AudioChannel.Motion, this._data.Result.LongAttackData.End_Audio, this._bullet.Position);
				}
			}
		}

		// Token: 0x0600C993 RID: 51603 RVA: 0x002D4344 File Offset: 0x002D2544
		private void FakeDestroyBulletObject()
		{
			bool flag = this._bullet != null;
			if (flag)
			{
				Vector3 position = this._bullet.Position;
				Quaternion rotation = this._bullet.Rotation;
				bool flag2 = this._iFmod != null;
				if (flag2)
				{
					XSingleton<XAudioMgr>.singleton.StopSound(this._iFmod);
					this._iFmod.Destroy();
					XSingleton<XUpdater.XUpdater>.singleton.XPlatform.ReturnClass(EClassType.ERuntimeFMOD, this._iFmod);
					this._iFmod = null;
				}
				XSingleton<XFxMgr>.singleton.DestroyFx(this._bullet, true);
				this._bullet = null;
				this._bullet = XSingleton<XFxMgr>.singleton.CreateFx("", null, true);
				this._bullet.Position = position;
				this._bullet.Rotation = rotation;
				this._bullet.SetActive(true);
			}
		}

		// Token: 0x0600C994 RID: 51604 RVA: 0x002D4420 File Offset: 0x002D2620
		public void Destroy(bool leave = false)
		{
			XSingleton<XTimerMgr>.singleton.KillTimer(this._tail_results_token);
			bool flag = !leave && this._data.Result.LongAttackData.TriggerAtEnd_Count == 0 && (this._data.Demonstration || XEntity.ValideEntity(this._data.Firer));
			if (flag)
			{
				this.TailResult(true);
			}
			bool flag2 = this._bullet != null;
			if (flag2)
			{
				bool flag3 = this._iFmod != null;
				if (flag3)
				{
					XSingleton<XAudioMgr>.singleton.StopSound(this._iFmod);
					this._iFmod.Destroy();
					XSingleton<XUpdater.XUpdater>.singleton.XPlatform.ReturnClass(EClassType.ERuntimeFMOD, this._iFmod);
					this._iFmod = null;
				}
				XSingleton<XFxMgr>.singleton.DestroyFx(this._bullet, true);
				this._bullet = null;
			}
			bool flag4 = this._data.Result.LongAttackData.Refine_Cycle > 0f;
			if (flag4)
			{
				int i = 0;
				int count = this._hurt_target.Count;
				while (i < count)
				{
					XBullet.XBulletTarget xbulletTarget = this._hurt_target[i];
					XSingleton<XTimerMgr>.singleton.KillTimer(xbulletTarget.TimerToken);
					i++;
				}
			}
			XSingleton<XBulletMgr>.singleton.ReturnSmallBuffer(ref this._hurt_target);
		}

		// Token: 0x0600C995 RID: 51605 RVA: 0x002D4578 File Offset: 0x002D2778
		public void OnResult(XEntity target)
		{
			bool flag = XEntity.ValideEntity(target);
			if (flag)
			{
				XBullet.XBulletTarget xbulletTarget;
				xbulletTarget.HurtCount = 0;
				xbulletTarget.TimerToken = 0U;
				xbulletTarget.TargetID = 0UL;
				int num = -1;
				int i = 0;
				int count = this._hurt_target.Count;
				while (i < count)
				{
					xbulletTarget = this._hurt_target[i];
					bool flag2 = xbulletTarget.TargetID == target.ID;
					if (flag2)
					{
						num = i;
						break;
					}
					i++;
				}
				bool flag3 = num < 0;
				if (flag3)
				{
					xbulletTarget = default(XBullet.XBulletTarget);
					xbulletTarget.TargetID = target.ID;
					num = this._hurt_target.Count;
					this._hurt_target.Add(xbulletTarget);
				}
				XSingleton<XTimerMgr>.singleton.KillTimer(xbulletTarget.TimerToken);
				xbulletTarget.Hurtable = false;
				xbulletTarget.HurtCount++;
				xbulletTarget.TimerToken = ((this._data.Result.LongAttackData.Refine_Cycle > 0f) ? XSingleton<XTimerMgr>.singleton.SetTimer(this._data.Result.LongAttackData.Refine_Cycle, new XTimerMgr.ElapsedEventHandler(this.OnRefined), target.ID) : 0U);
				this._hurt_target[num] = xbulletTarget;
				bool flag4 = this._data.TriggerMove && XEntity.ValideEntity(this._data.Firer);
				if (flag4)
				{
					Vector3 vector = (this._data.Firer.EngineObject.Position - target.EngineObject.Position).normalized * target.RealEntity.Radius;
					this._data.Firer.CorrectMe(target.EngineObject.Position + vector, this._data.Firer.EngineObject.Forward, false, false);
				}
			}
			bool triggerOnce = this._data.Result.LongAttackData.TriggerOnce;
			if (triggerOnce)
			{
				this.OnOnceTriggered();
			}
		}

		// Token: 0x0600C996 RID: 51606 RVA: 0x002D4788 File Offset: 0x002D2988
		private void OnOnceTriggered()
		{
			bool triggerOnce = this._data.Result.LongAttackData.TriggerOnce;
			if (triggerOnce)
			{
				bool isPingPong = this._data.Result.LongAttackData.IsPingPong;
				if (isPingPong)
				{
					this.OnPingPong();
				}
				else
				{
					this._active = false;
				}
			}
		}

		// Token: 0x0600C997 RID: 51607 RVA: 0x002D47DC File Offset: 0x002D29DC
		private void Result(XEntity target, bool cycle = true)
		{
			bool demonstration = this._data.Demonstration;
			if (!demonstration)
			{
				bool flag = target == null;
				if (flag)
				{
					XSkill.SkillResult(this, this._bullet.Forward, this._bullet.Position, cycle);
				}
				else
				{
					bool flag2 = !this._data.Result.Attack_Only_Target || target == this._data.Target;
					if (flag2)
					{
						bool syncMode = XSingleton<XGame>.singleton.SyncMode;
						if (syncMode)
						{
							bool triggerOnce = this._data.Result.LongAttackData.TriggerOnce;
							if (triggerOnce)
							{
								this.OnOnceTriggered();
							}
						}
						else
						{
							Vector3 hitdir = target.EngineObject.Position - this._origin;
							hitdir.y = 0f;
							hitdir.Normalize();
							XSkill.SkillResult(this._data.Token, this._data.Firer, this._data.SkillCore, this, this._data.Sequnce, this._data.ResultID, this._data.ResultTime, hitdir, target);
						}
						bool triggerOnce2 = this._data.Result.LongAttackData.TriggerOnce;
						if (triggerOnce2)
						{
							this._hit_triggered = true;
						}
					}
				}
			}
		}

		// Token: 0x0600C998 RID: 51608 RVA: 0x002D492C File Offset: 0x002D2B2C
		public void Update(float fDeltaT)
		{
			bool flag = !this._active;
			if (!flag)
			{
				this._elapsed += fDeltaT;
				float num = 0f;
				Vector3 vector = Vector3.forward;
				switch (this._data.Result.LongAttackData.Type)
				{
				case XResultBulletType.Sphere:
				case XResultBulletType.Plane:
					num = ((this._elapsed > this._data.Running && this._elapsed < this._data.Life) ? 0f : this._data.Velocity) * fDeltaT;
					vector = this._bullet.Forward;
					break;
				case XResultBulletType.Satellite:
				{
					bool flag2 = this._elapsed - fDeltaT <= XCommon.XEps;
					if (flag2)
					{
						Vector3 position = this._data.Firer.EngineObject.Position + this._data.BulletRay.direction * this._data.Result.LongAttackData.RingRadius;
						position.y = this._bullet.Position.y;
						this._bullet.Position = position;
						num = 0f;
						vector = XSingleton<XCommon>.singleton.HorizontalRotateVetor3(this._data.Firer.MoveObj.Forward, (float)((this._data.Result.LongAttackData.Palstance < 0f) ? -90 : 90), true);
					}
					else
					{
						Vector3 vector2 = XSingleton<XCommon>.singleton.HorizontalRotateVetor3(this._data.BulletRay.direction, this._data.Result.LongAttackData.Palstance * (this._elapsed - fDeltaT), true) * this._data.Result.LongAttackData.RingRadius;
						Vector3 vector3 = XSingleton<XCommon>.singleton.HorizontalRotateVetor3(this._data.BulletRay.direction, this._data.Result.LongAttackData.Palstance * this._elapsed, true) * this._data.Result.LongAttackData.RingRadius;
						this._bullet.Forward = XSingleton<XCommon>.singleton.Horizontal(vector3 - vector2);
						vector3 += this._data.Firer.EngineObject.Position;
						Vector3 vector4 = vector3 - this._bullet.Position;
						vector4.y = 0f;
						num = vector4.magnitude;
						vector = vector4.normalized;
					}
					break;
				}
				case XResultBulletType.Ring:
				{
					Vector3 position2 = this._data.Firer.EngineObject.Position;
					position2.y = this._bullet.Position.y;
					this._bullet.Position = position2;
					break;
				}
				}
				bool flag3 = this._data.Result.LongAttackData.IsPingPong && this._pingpong;
				if (flag3)
				{
					bool flag4 = !this._data.Demonstration && !XEntity.ValideEntity(this._data.Firer);
					if (flag4)
					{
						this._active = false;
						return;
					}
					Vector3 vector5 = this._data.Firer.EngineObject.Position - this._bullet.Position;
					vector5.y = 0f;
					bool flag5 = num * num >= vector5.sqrMagnitude;
					if (flag5)
					{
						this._active = false;
						return;
					}
					vector = vector5.normalized;
				}
				else
				{
					bool flag6 = this._data.Result.LongAttackData.Follow && XEntity.ValideEntity(this._data.Target);
					if (flag6)
					{
						vector = XSingleton<XCommon>.singleton.Horizontal(this._data.Target.EngineObject.Position - this._bullet.Position);
					}
				}
				bool flag7 = this._data.Result.LongAttackData.Type != XResultBulletType.Satellite;
				if (flag7)
				{
					this._bullet.Forward = vector;
				}
				Vector3 vector6 = vector * num;
				this._origin = this._bullet.Position;
				this._bullet.Position += vector6;
				bool demonstration = this._data.Demonstration;
				if (!demonstration)
				{
					float num2 = 0f;
					bool flag8 = !XSingleton<XScene>.singleton.TryGetTerrainY(this._bullet.Position, out num2);
					if (flag8)
					{
						bool isPingPong = this._data.Result.LongAttackData.IsPingPong;
						if (isPingPong)
						{
							this.OnPingPong();
						}
						else
						{
							this._active = false;
						}
					}
					else
					{
						bool staticCollider = this._data.Result.LongAttackData.StaticCollider;
						if (staticCollider)
						{
							bool flag9 = num2 < 0f;
							if (flag9)
							{
								bool isPingPong2 = this._data.Result.LongAttackData.IsPingPong;
								if (isPingPong2)
								{
									this.OnPingPong();
								}
								else
								{
									this._active = false;
								}
								return;
							}
						}
						bool dynamicCollider = this._data.Result.LongAttackData.DynamicCollider;
						if (dynamicCollider)
						{
							bool flag10 = !XSingleton<XScene>.singleton.CheckDynamicBlock(this._origin, this._bullet.Position);
							if (flag10)
							{
								bool isPingPong3 = this._data.Result.LongAttackData.IsPingPong;
								if (isPingPong3)
								{
									this.OnPingPong();
								}
								else
								{
									this._active = false;
								}
								return;
							}
						}
						bool flag11 = !this._data.HasTarget;
						if (flag11)
						{
							bool flyWithTerrain = this._data.FlyWithTerrain;
							if (flyWithTerrain)
							{
								Vector3 position3 = this._bullet.Position;
								position3.y = num2 + this._data.InitHeight;
								this._bullet.Position = position3;
							}
							else
							{
								bool flag12 = Mathf.Abs(this._bullet.Position.y - num2) < 0.2f || num2 < 0f;
								if (flag12)
								{
									this._active = false;
									bool flag13 = !string.IsNullOrEmpty(this._data.Result.LongAttackData.HitGround_Fx);
									if (flag13)
									{
										XFx xfx = XSingleton<XFxMgr>.singleton.CreateFx(this._data.Result.LongAttackData.HitGround_Fx, null, true);
										xfx.DelayDestroy = this._data.Result.LongAttackData.HitGroundFx_LifeTime;
										Quaternion rotation = this._bullet.Rotation;
										rotation = XSingleton<XCommon>.singleton.RotateToGround(this._bullet.Position, this._bullet.Forward);
										xfx.Play(this._bullet.Position, rotation, Vector3.one, 1f);
										XSingleton<XFxMgr>.singleton.DestroyFx(xfx, false);
									}
									return;
								}
							}
							vector6 = this._bullet.Position - this._origin;
						}
						bool syncMode = XSingleton<XGame>.singleton.SyncMode;
						if (!syncMode)
						{
							bool manipulation = this._data.Result.LongAttackData.Manipulation;
							if (manipulation)
							{
								List<XEntity> opponent = XSingleton<XEntityMgr>.singleton.GetOpponent(this._data.Firer);
								Vector3 position4 = this._bullet.Position;
								for (int i = 0; i < opponent.Count; i++)
								{
									XEntity xentity = opponent[i];
									bool flag14 = !XEntity.ValideEntity(xentity);
									if (!flag14)
									{
										Vector3 vector7 = position4 - xentity.EngineObject.Position;
										vector7.y = 0f;
										bool flag15 = vector7.magnitude < this._data.Result.LongAttackData.ManipulationRadius;
										if (flag15)
										{
											float num3 = this._data.Result.LongAttackData.ManipulationForce * fDeltaT;
											xentity.ApplyMove(vector7.normalized * Mathf.Min(vector7.magnitude, num3));
										}
									}
								}
							}
							bool hit_triggered = this._hit_triggered;
							if (!hit_triggered)
							{
								bool withCollision = this._data.Result.LongAttackData.WithCollision;
								if (withCollision)
								{
									switch (this._data.Result.LongAttackData.Type)
									{
									case XResultBulletType.Sphere:
									case XResultBulletType.Satellite:
									{
										Vector3 vector8;
										vector8 = new Vector3(vector6.x, 0f, vector6.z);
										float num4 = vector8.magnitude * 0.5f;
										vector.y = 0f;
										float num5 = (vector.sqrMagnitude == 0f) ? 0f : Vector3.Angle(Vector3.right, vector);
										bool flag16 = num5 > 0f && XSingleton<XCommon>.singleton.Clockwise(Vector3.right, vector);
										if (flag16)
										{
											num5 = -num5;
										}
										XBullet.BulletCollideUnit(this._data.Firer, new Vector3(this._origin.x + vector.x * num4, 0f, this._origin.z + vector.z * num4), num4, num5, this._data.Radius, this);
										break;
									}
									case XResultBulletType.Plane:
										XBullet.PlaneBulletCollideUnit(this._data.Firer, this._origin, vector6, this._data.Radius, this);
										break;
									case XResultBulletType.Ring:
									{
										float num6 = XSingleton<XCommon>.singleton.IsGreater(this._elapsed, this._data.Life) ? 0f : (this._data.Result.LongAttackData.RingFull ? (XSingleton<XCommon>.singleton.IsGreater(this._elapsed, this._data.Life * 0.5f) ? (this._data.Life - this._elapsed) : this._elapsed) : this._elapsed);
										float num7 = num6 * this._data.Result.LongAttackData.RingVelocity;
										float or = num7 + this._data.Result.LongAttackData.RingRadius;
										XBullet.RingBulletCollideUnit(this._data.Firer, num7, or, this);
										break;
									}
									}
								}
							}
						}
					}
				}
			}
		}

		// Token: 0x0600C999 RID: 51609 RVA: 0x002D53A8 File Offset: 0x002D35A8
		private static void RingBulletCollideUnit(XEntity firer, float ir, float or, XBullet bullet)
		{
			Vector3 position = firer.EngineObject.Position;
			List<XEntity> opponent = XSingleton<XEntityMgr>.singleton.GetOpponent(firer);
			for (int i = 0; i < opponent.Count; i++)
			{
				bool flag = !XEntity.ValideEntity(opponent[i]);
				if (!flag)
				{
					bool flag2 = false;
					bool flag3 = opponent[i].Present != null && opponent[i].Present.PresentLib.Huge;
					if (flag3)
					{
						SeqListRef<float> hugeMonsterColliders = opponent[i].Present.PresentLib.HugeMonsterColliders;
						for (int j = 0; j < hugeMonsterColliders.Count; j++)
						{
							float num = hugeMonsterColliders[j, 2] * opponent[i].Scale;
							Vector3 vector = opponent[i].HugeMonsterColliderCenter(j) - position;
							vector.y = 0f;
							float sqrMagnitude = vector.sqrMagnitude;
							flag2 = (sqrMagnitude > ir * ir && sqrMagnitude < or * or);
							bool flag4 = flag2;
							if (flag4)
							{
								break;
							}
						}
					}
					else
					{
						Vector3 vector2 = opponent[i].RadiusCenter - position;
						vector2.y = 0f;
						float sqrMagnitude2 = vector2.sqrMagnitude;
						flag2 = (sqrMagnitude2 > ir * ir && sqrMagnitude2 < or * or);
					}
					bool flag5 = flag2;
					if (flag5)
					{
						bullet.Result(opponent[i], true);
					}
					bool flag6 = bullet.IsExpired();
					if (flag6)
					{
						break;
					}
				}
			}
		}

		// Token: 0x0600C99A RID: 51610 RVA: 0x002D5534 File Offset: 0x002D3734
		private static void PlaneBulletCollideUnit(XEntity firer, Vector3 origin, Vector3 move, float r, XBullet bullet)
		{
			Vector3 vector = XSingleton<XCommon>.singleton.HorizontalRotateVetor3(move, 90f, true);
			Vector3 q = origin + vector * r;
			Vector3 q2 = origin - vector * r;
			List<XEntity> opponent = XSingleton<XEntityMgr>.singleton.GetOpponent(firer);
			for (int i = 0; i < opponent.Count; i++)
			{
				bool flag = !XEntity.ValideEntity(opponent[i]);
				if (!flag)
				{
					bool flag2 = false;
					bool flag3 = opponent[i].Present != null && opponent[i].Present.PresentLib.Huge;
					if (flag3)
					{
						SeqListRef<float> hugeMonsterColliders = opponent[i].Present.PresentLib.HugeMonsterColliders;
						for (int j = 0; j < hugeMonsterColliders.Count; j++)
						{
							float num = hugeMonsterColliders[j, 2] * opponent[i].Scale;
							Vector3 vector2 = opponent[i].HugeMonsterColliderCenter(j);
							flag2 = XSingleton<XCommon>.singleton.IsLineSegmentCross(vector2, vector2 - move, q, q2);
							bool flag4 = flag2;
							if (flag4)
							{
								break;
							}
						}
					}
					else
					{
						Vector3 radiusCenter = opponent[i].RadiusCenter;
						flag2 = XSingleton<XCommon>.singleton.IsLineSegmentCross(radiusCenter, radiusCenter - move, q, q2);
					}
					bool flag5 = flag2;
					if (flag5)
					{
						bullet.Result(opponent[i], true);
					}
					bool flag6 = bullet.IsExpired();
					if (flag6)
					{
						break;
					}
				}
			}
		}

		// Token: 0x0600C99B RID: 51611 RVA: 0x002D56C8 File Offset: 0x002D38C8
		private static void BulletCollideUnit(XEntity firer, Vector3 rectcenter, float hlen, float rotation, float r, XBullet bullet)
		{
			List<XEntity> opponent = XSingleton<XEntityMgr>.singleton.GetOpponent(firer);
			for (int i = 0; i < opponent.Count; i++)
			{
				bool flag = !XEntity.ValideEntity(opponent[i]);
				if (!flag)
				{
					bool flag2 = false;
					bool flag3 = opponent[i].Present != null && opponent[i].Present.PresentLib.Huge;
					if (flag3)
					{
						SeqListRef<float> hugeMonsterColliders = opponent[i].Present.PresentLib.HugeMonsterColliders;
						for (int j = 0; j < hugeMonsterColliders.Count; j++)
						{
							float num = hugeMonsterColliders[j, 2] * opponent[i].Scale;
							Vector3 vector = opponent[i].HugeMonsterColliderCenter(j);
							vector -= rectcenter;
							vector.y = 0f;
							flag2 = XSingleton<XCommon>.singleton.IsRectCycleCross(hlen, r, vector, num);
							bool flag4 = !flag2;
							if (flag4)
							{
								float num2 = num;
								float magnitude = vector.magnitude;
								flag2 = (magnitude - num2 < r);
							}
							bool flag5 = flag2;
							if (flag5)
							{
								break;
							}
						}
					}
					else
					{
						Vector3 vector2 = opponent[i].RadiusCenter;
						vector2 -= rectcenter;
						vector2.y = 0f;
						vector2 = XSingleton<XCommon>.singleton.HorizontalRotateVetor3(vector2, rotation, false);
						flag2 = XSingleton<XCommon>.singleton.IsRectCycleCross(hlen, r, vector2, opponent[i].Radius);
						bool flag6 = !flag2;
						if (flag6)
						{
							float radius = opponent[i].Radius;
							float magnitude2 = vector2.magnitude;
							flag2 = (magnitude2 - radius < r);
						}
					}
					bool flag7 = flag2;
					if (flag7)
					{
						bullet.Result(opponent[i], true);
					}
					bool flag8 = bullet.IsExpired();
					if (flag8)
					{
						break;
					}
				}
			}
		}

		// Token: 0x04005911 RID: 22801
		private ulong _id = 0UL;

		// Token: 0x04005912 RID: 22802
		private ulong _extra_id = 0UL;

		// Token: 0x04005913 RID: 22803
		private bool _active = true;

		// Token: 0x04005914 RID: 22804
		private bool _effectual = true;

		// Token: 0x04005915 RID: 22805
		private bool _pingpong = false;

		// Token: 0x04005916 RID: 22806
		private bool _hit_triggered = false;

		// Token: 0x04005917 RID: 22807
		private int _tail_results = 0;

		// Token: 0x04005918 RID: 22808
		private uint _tail_results_token = 0U;

		// Token: 0x04005919 RID: 22809
		private float _elapsed = 0f;

		// Token: 0x0400591A RID: 22810
		private XFx _bullet = null;

		// Token: 0x0400591B RID: 22811
		private XBulletCore _data;

		// Token: 0x0400591C RID: 22812
		private Vector3 _origin = Vector3.zero;

		// Token: 0x0400591D RID: 22813
		private SmallBuffer<XBullet.XBulletTarget> _hurt_target;

		// Token: 0x0400591E RID: 22814
		private IXFmod _iFmod;

		// Token: 0x020019E1 RID: 6625
		public struct XBulletTarget
		{
			// Token: 0x04008066 RID: 32870
			public ulong TargetID;

			// Token: 0x04008067 RID: 32871
			public uint TimerToken;

			// Token: 0x04008068 RID: 32872
			public bool Hurtable;

			// Token: 0x04008069 RID: 32873
			public int HurtCount;
		}
	}
}
